//
//  MediaShareBBUtilityMethods.m
//  MediaShareBB
//
//  Created by Artak Gevorgyan on 7/4/13.
//  Copyright (c) 2013 InnoriseEntertainment. All rights reserved.
//

#import "MediaShareBBUtilityMethods.h"

@implementation MediaShareBBUtilityMethods

+(UIImage*) imageFromData:(NSData*) data {
	UIImage* image = [UIImage imageWithData:data];
	return image;
}

+(NSData*) dataFromImage:(UIImage*) image {
	NSData* data = UIImagePNGRepresentation(image);
	return data;
}

+(NSString*) getCurrentData {
	NSDate* date = [NSDate date];
	NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
	NSTimeZone* zone = [NSTimeZone localTimeZone];
	[formatter setTimeZone:zone];
	[formatter setDateFormat:@"yyyy_MM_dd_HH_mm_ss"];
	NSString* s = [formatter stringFromDate:date];
	return s;
}

+(BOOL) isInstagramAppInstalled {
    NSURL* url = [NSURL URLWithString:@"instagram://app"];
    return [[UIApplication sharedApplication] canOpenURL:url];
}

+(BOOL) isObject:(id) object respondsToSelector:(SEL) selector {
	return object != nil && [object respondsToSelector:selector];
}

+(BOOL) isEmpty:(id) object {
    return (object == nil)
    || (object == [NSNull null])
    || ([object respondsToSelector:@selector(length)] && [(NSData*)object length] == 0)
    || ([object respondsToSelector:@selector(count)] && [(NSArray*)object count] == 0);
}

@end
